<extend name="Public:base" />
<block name="header_js">

<script type="text/javascript">
    $(function(){
         $('#checkAll').click(function(){

            //attr('checked')不管用1.7+后  
            //var checked = $(this).prop('checked');//this.checked;//IE9+
            var checked = $(this).prop('checked');             
            var inputs = $('#accessContent input[type=checkbox]');
     
            if (checked) {
                inputs.prop('checked', true);
            }else {
                inputs.prop('checked', false);
            }
            
        });
        //选中全部子级
        $('input[level=1]').click(function(){

            var checked = $(this).prop('checked');            
            var inputs = $(this).parents('.panel').find('.panel-body input');     
            if (checked) {
                inputs.prop('checked', true);
            }else {
                inputs.prop('checked', false);
            }
            
        });

        //选中父级
        $('input[level=2]').click(function(){

            var checked = $(this).prop('checked');            
            var parentInput = $(this).parents('.panel').find('.panel-heading input');
  
            if (checked) {
                parentInput.prop('checked', true);
            }
            
        });



    });
 
</script>
</block>

<block name="content">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em> 
            {$meta_title}       
            </h3> 
        </div>
        
    </div>

    <div class="row margin-botton">
        <div class="col-lg-12">
            <div class="btn-group btn-group-md">           
                <button class="btn btn-primary" type="button" onclick="goUrl('{:U('index')}')"><em class="glyphicon glyphicon-chevron-left"></em> 返回</button>
                <button class="btn btn-info" type="button" onclick="doGoSubmit('{:U('access')}', 'formAccess')"><em class="glyphicon glyphicon-saved"></em> 更新权限</button>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 column">
            <p>
                <label class="checkbox-inline" for="checkAll">                    
                    <input type="checkbox" id="checkAll"  />
                    <span class=" label label-default">全部选择</span>
                </label>
            </p>
            
        </div>
    </div>


    <div class="row" id="accessContent">

        <form method="post" action="{:U('access')}" id="formAccess">
            <input type="hidden" name="id" value="{$id}">
            <div class="col-lg-12">
                <volist name="vlist" id="vo">
                <div class="panel panel-info">
                        <div class="panel-heading">
                            <div class="row">
                                    <div class="col-xs-8">
                                        <h3 class="panel-title">
                                        <input class="uniform" type="checkbox" name="roleslist[]" value="{$vo.id}" level="1" <if condition="in_array($vo['id'], $roles)">checked="checked"</if> /> {$vo.title}
                                        </h3>
                                    </div>                                
                                </div>
                            
                        </div>
                        <div class="panel-body xyh-panel-body">
                            <notempty name="vo['_child']">
                                <volist name="vo['_child']" id="vo2"> 
                                    <label class="checkbox-inline">                    
                                        <input type="checkbox" name="roleslist[]" value="{$vo2.id}"  level="2" <if condition="in_array($vo2['id'], $roles)">checked="checked"</if> />
                                        <span class=" label label-primary">{$vo2.title}</span>
                                    </label>                
                                 &nbsp;&nbsp;
                                </volist>
                            </notempty> 
                        </div>
                    </div>
                
                </volist>

            </div>
        
       </form>

    </div>

</block>